You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
613 B
16 lines
613 B
import { deleteDocument } from "../../service/agent-document";
|
|
import { requireUser } from "#server/utils/context";
|
|
|
|
export default defineWrappedResponseHandler(async (event) => {
|
|
const user = await requireUser(event);
|
|
|
|
const idParam = getRouterParam(event, "id");
|
|
if (!idParam) return R.throwError(400, "缺少文档 ID", null);
|
|
const id = parseInt(idParam);
|
|
if (isNaN(id)) return R.throwError(400, "文档 ID 格式不正确", null);
|
|
|
|
const deleted = await deleteDocument(id, user.id);
|
|
if (!deleted) return R.throwError(404, "文档不存在或无权访问", null);
|
|
|
|
return R.success(null);
|
|
});
|
|
|